<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>


<%@ include file="/commons/global.jsp"%>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<title>慢性病证</title>
</head>
<body class="easyui-layout" data-options="fit:true"
	style="font-family: '微软雅黑'">
	<div
		data-options="region:'center',split:true,border:false,title:'参合人员列表'">
		<div id="familyInfoTb" style="height: auto">
			<form id="searchFrom" action="">
				<input type="text" name="filter_LIKES_name"
					class="easyui-validatebox" data-options="width:150,prompt: '姓名'" />
				<span class="toolbar-item dialog-tool-separator"></span> <a
					href="javascript(0)" class="easyui-linkbutton" plain="true"
					iconCls="icon-search" onclick="cx()">查询</a>
			</form>
		</div>
		<table id="familyInfoDg"></table>
	</div>
	<div
		data-options="region:'south',border:true,collapsible:false,title:'慢性病证列表'"
		style="height: 400px">
		<div id="partInstTb" style="height: auto">
			<div>
				<a href="javascript:void(0)" class="easyui-linkbutton"
					iconCls="icon-remove" plain="true" data-options="disabled:false"
					onclick="infoDel()">删除</a> <span
					class="toolbar-item dialog-tool-separator"></span> <a
					href="javascript:void(0)" class="easyui-linkbutton"
					iconCls="icon-edit" plain="true" onclick="infoUpd()">修改</a> <span
					class="toolbar-item dialog-tool-separator"></span>
			</div>
		</div>
		<table id="partInstDg"></table>
	</div>
	<div id="dlg"></div>
	<script type="text/javascript">
		var dg;
		var familyInfoDg;
		var partInstDg;
		var d;
		//创建查询对象并查询
		function cx() {
			var obj = $("#searchFrom").serializeObject();
			familyInfoDg.datagrid('load', obj);
		}
		//时间格式化
		function dateFormatter(value) {
			var date = new Date(value);
			return dateFtt('yyyy-MM-dd hh:mm:ss', date);
		}

		$(function() {
			familyInfoDg = $('#familyInfoDg').datagrid(
					{

						url : '${path}/familyInfo/dataGridAll',
						striped : true,
						rownumbers : true,
						pagination : true,
						singleSelect : true,
						idField : 'id',
						sortName : 'id',
						sortOrder : 'asc',
						pageSize : 20,
						pageList : [ 10, 20, 30, 40, 50, 100, 200, 300, 400,
								500 ],
						frozenColumns : [ [ {
							width : '50',
							title : '编号',
							field : 'id',
							sortable : true
						}, {
							width : '80',
							title : '成员编号',
							field : 'familyInfoNo',
							sortable : true
						}, {
							width : '150',
							title : '家庭编号',
							field : 'familyNo',
							sortable : true
						}, {
							width : '150',
							title : '身份证号',
							field : 'cardNo',
							sortable : true
						},

						{
							width : '50',
							title : '与户主关系',
							field : 'relaType',
							sortable : true
						}, {
							width : '50',
							title : '是否参合',
							field : 'partState',
							sortable : true
						}, {
							width : '50',
							title : '姓名',
							field : 'name',
							sortable : true
						}, {
							width : '50',
							title : '年齡',
							field : 'age',
							sortable : true
						}, {
							width : '50',
							title : '性別',
							field : 'gender',
							sortable : true
						}, {
							width : '50',
							title : '参合状态',
							field : 'partState',
							sortable : true
						}, {
							width : '100',
							title : '慢性病证号',
							field : 'illCardNo',
							sortable : true
						}, {
							width : '100',
							title : '操作',
							field : 'opt',
							sortable : true,
							formatter : partOper
						}
						//	{field:'opt',title:'操作',width:80,formatter:partOper}  
						] ],
						headerContextMenu : [
								{
									text : "冻结该列",
									disabled : function(e, field) {
										return familyInfoDg.datagrid(
												"getColumnFields", true)
												.contains(field);
									},
									handler : function(e, field) {
										familyInfoDg.datagrid("freezeColumn",
												field);
									}
								},
								{
									text : "取消冻结该列",
									disabled : function(e, field) {
										return familyInfoDg.datagrid(
												"getColumnFields", false)
												.contains(field);
									},
									handler : function(e, field) {
										familyInfoDg.datagrid("unfreezeColumn",
												field);
									}
								} ],
						enableHeaderClickMenu : true,
						enableHeaderContextMenu : true,
						enableRowContextMenu : false,
						toolbar : '#familyInfoTb',
						onClickRow : function(rowIndex, rowData) {
							var cardNo = rowData.cardNo;
							partInstDg = $('#partInstDg');
							partInstDg.datagrid({
								url : '${path}/illCard/dataGrid?cardNo='
										+ cardNo
							});
							partInstDg.datagrid('reload', {
								filter_EQS_cardNo : cardNo
							})
						}
					});
		});

		$(function() {
			partInstDg = $('#partInstDg').datagrid(
					{
						method : "get",
						//url:'${ctx}/exp/partInst/json', 
						striped : true,
						rownumbers : true,
						pagination : true,
						singleSelect : true,
						idField : 'id',
						sortName : 'id',
						sortOrder : 'asc',
						pageSize : 20,
						pageList : [ 10, 20, 30, 40, 50, 100, 200, 300, 400,
								500 ],
						frozenColumns : [ [ {
							field : 'id',
							title : 'id',
							width : '100'
						}, {
							field : 'illCardNo',
							title : '慢性病证编号',
							width : '100'
						}, {
							field : 'partNo',
							title : '参合证号',
							width : '100'
						}, {
							field : 'cardNo',
							title : '身份证号',
							width : '100'
						}, {
							field : 'illName',
							title : '疾病名称',
							width : '100'
						}, {
							field : 'startDay',
							title : '起始时间',
							width : '100',
							//formatter : dateFormatter
						}, {
							field : 'endDay',
							title : '终止时间',
							width : '100',
							//formatter : dateFormatter
						},{
							field : 'action',
							title : '操作',
							width : 200,
							formatter : function(value, row, index) {
								var str = '';
								<shiro:hasPermission name="/illCard/edit">
								str += $
										.formatString(
												'<a href="javascript:void(0)" class="family-easyui-linkbutton-edit" data-options="plain:true,iconCls:\'fi-pencil icon-blue\'" onclick="illCardEditFun(\'{0}\');" >编辑</a>',
												row.id);
								</shiro:hasPermission>
								<shiro:hasPermission name="/illCard/delete">
								str += '&nbsp;&nbsp;|&nbsp;&nbsp;';
								str += $
										.formatString(
												'<a href="javascript:void(0)" class="family-easyui-linkbutton-del" data-options="plain:true,iconCls:\'fi-x icon-red\'" onclick="illCardDeleteFun(\'{0}\');" >删除</a>',
												row.id);
								</shiro:hasPermission>
								return str;
							}
						} ] ],
						headerContextMenu : [
								{
									text : "冻结该列",
									disabled : function(e, field) {
										return partInstDg.datagrid(
												"getColumnFields", true)
												.contains(field);
									},
									handler : function(e, field) {
										partInstDg.datagrid("freezeColumn",
												field);
									}
								},
								{
									text : "取消冻结该列",
									disabled : function(e, field) {
										return partInstDg.datagrid(
												"getColumnFields", false)
												.contains(field);
									},
									handler : function(e, field) {
										partInstDg.datagrid("unfreezeColumn",
												field);
									}
								} ],
						enableHeaderClickMenu : true,
						enableHeaderContextMenu : true,
						enableRowContextMenu : false,
						toolbar : '#partInstTb'
					});
		});


		//弹窗修改
		function infoUpd() {
			var row = partInstDg.datagrid('getSelected');
			if (rowIsNull(row))
				return;
			d = $("#dlg").dialog({
				title : '修改',
				width : 380,
				height : 340,
				//   href:'${ctx}/exp/illCard/update/'+row.illCardNo,
				maximizable : true,
				modal : true,
				buttons : [ {
					text : '修改',
					handler : function() {
						$('#mainform').submit();
						partInstDg.datagrid('reload');
					}
				}, {
					text : '取消',
					handler : function() {
						d.panel('close');
					}
				} ]
			});
		}

		//查看
		function infoLook() {
			var row = familyInfoDg.datagrid('getSelected');
			if (rowIsNull(row))
				return;
			d = $("#dlg").dialog({
				title : '查看',
				width : 380,
				height : 340,
				href : '${path}/family/manager',
				maximizable : true,
				modal : true,
				buttons : [ {
					text : '取消',
					handler : function() {
						d.panel('close');
					}
				} ]
			});
		}
		//慢性病证办理
		function partOper(val, row, index) {
			if (row.illCardNo == '0' && row.partState == '已参合') {
				return '<a href="#" onclick="partAdd(\'' + row.cardNo
						+ '\')">慢性病证办理</a>';
			} else if (row.illCardNo != '0') {
				return '已办理';
			} else {
				return '未参合，不能办理';
			}
		}
		/**
		 * 删除
		 */
		function illCardDeleteFun(id) {
			//alert(id);
			parent.$.messager.confirm('询问', '您是否要删除当前角色？', function(b) {
				if (b) {
					progressLoad();
					$.post('${path}/illCard/delete', {
						id : id
					}, function(result) {
						if (result.success) {
							parent.$.messager.alert('提示', result.msg, 'info');
							//familyDataGrid.datagrid('reload');
						}
						progressClose();
					}, 'JSON');
				}
			});
		}

		//参合登记頁面
		function partAdd(cardNo) {
			d = $("#dlg").dialog({
				title : '慢性病证办理',
				width : 380,
				height : 380,
			    href:'${path}/illCard/addPage?cardNo='+cardNo,
				maximizable : true,
				modal : true,
				buttons : [ {
					text : '提交确认',
					handler : function() {
						$("#mainform").submit();
						partInstDg.datagrid('reload');
						familyInfoDg.datagrid('reload');
					}
				}, {
					text : '取消',
					handler : function() {
						d.panel('close');
					}
				} ]
			});
		}
	</script>
</body>
</html>